home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 41.zip
/
BS1 part 41
/
Compute`s Amiga resource 1.adf
/
Source
/
8ColorWbench
/
Colorbench.a
next >
Wrap
Text File
|
1989-02-08
|
3KB
|
129 lines
;*************************************************************************
;
; Colorbench.a
;
; Double the number of colors available on the Workbench screen by
; adding another bitplane.
;
;*************************************************************************
; Constants
_AbsExecBase EQU 4 ;base addr for Exec
_CloseLibrary EQU -414
_RemakeDisplay EQU -384
_BltClear EQU -300
_AllocRaster EQU -492
_OpenWorkBench EQU -210
_OpenLibrary EQU -552
LIB_VERSION EQU 32 ;KS 1.2 or higher
BITMAP EQU 88 ;offset to BitMap structure
DEPTH EQU 5 ;offset to number of bitplanes
WIDTH EQU 12 ;offset to bitplane width
HEIGHT EQU 14 ;offset to bitplane height
PLANES EQU 16 ;offset to 3rd bitplane ptr
SECTION Program,CODE
Start:
movea.l _AbsExecBase,a6 ;get ptr to Exec library
; open intuition library
lea IntuitionName,a1 ;ptr to "intuition.library"
moveq.l #LIB_VERSION,d0 ;set library version
jsr _OpenLibrary(a6) ;call OpenLibrary
move.l d0,IntuitionBase ;store the addr
beq Exit ;problem -- drop out
; open graphics library
lea GfxName,a1 ;ptr to "graphics.library"
moveq.l #LIB_VERSION,d0 ;set library version
jsr _OpenLibrary(a6) ;call OpenLibrary
move.l d0,GfxBase ;store the addr
beq CloseIntuition ;problem -- drop out
; get a ptr to the workbench screen structure using OpenWorkBench
movea.l IntuitionBase,a6 ;base addr of intuition library
jsr _OpenWorkBench(a6) ;call OpenWorkBench
move.l d0,Scr ;store the addr
beq AllDone ;problem -- drop out
; get a ptr to the BitMap structure within the screen's RastPort structure
movea.l Scr,a0
move.l BITMAP(a0),bm
; decide whether to add a bitplane
movea.l bm,a0
move.b DEPTH(a0),d0
cmpi.b #2,d0 ;2 bitplanes?
bne AllDone ;no
; yes, so add one bitplane
movea.l Scr,a0 ;addr of screen structure
move.w HEIGHT(a0),d1 ;height of bitmap
move.w WIDTH(a0),d0 ;width of bitmap
movea.l GfxBase,a6 ;base addr of graphics library
jsr _AllocRaster(a6) ;call AllocRaster
movea.l bm,a0 ;AllocRaster returns ptr in d0
move.l d0,PLANES(a0) ;bm->Plane[2] = d0
; clear the bitplane we just allocated
movea.l Scr,a0 ;
clr.l d0 ;put the number of bytes to
move.w WIDTH(a0),d0 ; clear in d0
divs #8,d0 ; bytes =
muls HEIGHT(a0),d0 ; WIDTH / 8 * HEIGHT
movea.l bm,a0
movea.l PLANES(a0),a1 ;put the addr of the bitplane in a1
clr.l d1 ;set flag to wait on BltClear
jsr _BltClear(a6) ;call BltClear
; set the number of bitplanes to 3
movea.l bm,a0
move.b #3,DEPTH(a0) ;bm->DEPTH = 3
; rebuild the display
movea.l IntuitionBase,a6
jsr _RemakeDisplay(a6) ;call RemakeDisplay
;fall through to AllDone
; finish by closing the libraries
AllDone:
movea.l GfxBase,a1 ;close graphics.library
movea.l _AbsExecBase,a6
jsr _CloseLibrary(a6) ;call CloseLibrary
CloseIntuition:
movea.l IntuitionBase,a1 ;close intuition.library
jsr _CloseLibrary(a6) ;call CloseLibrary
Exit:
rts ;back to CLI
SECTION InitData,DATA
IntuitionName:
dc.b 'intuition.library',0
GfxName:
dc.b 'graphics.library',0
SECTION UnInitData,BSS
Scr ds.l 1
bm ds.l 1
IntuitionBase ds.l 1
GfxBase ds.l 1
end